package com.fuqi.android.zhongcai.base.view.adapter;

import android.content.Context;

import com.fuqi.android.zhongcai.R;
import com.fuqi.android.zhongcai.business.shuig.request.result.QueryOrderListByDateResult;
import com.fuqi.android.zhongcai.sql.Dic;
import com.fuqi.android.zhongcai.sql.dao.SQLDao;

import java.util.List;

/**
 * create by juner
 * @Date 2016-8-31
 */


public class MonthOrderAdapter extends BaseRecyclerViewAdapter<QueryOrderListByDateResult>{
    Context mContext;

    public MonthOrderAdapter(Context context,List<QueryOrderListByDateResult> datas) {
        super(datas);
        this.mContext = context;
    }

    @Override
    protected int getLayoutId() {
        return R.layout.adapter_order_month;
    }

    @Override
    protected void onBind(ViewHolder holder, int position,QueryOrderListByDateResult data) {
        holder.setTextView(R.id.tv_contact_name, data.getCONTACT_NAME());
        holder.setTextView(R.id.tv_contact_phone, data.getCONTACT_PHONE());
        Dic dic = SQLDao.getInstance(mContext.getApplicationContext()).selectWithType(data.getORDER_TYPE());
        if(dic != null)
            holder.setTextView(R.id.tv_install, dic.getName());
        else
            holder.setTextView(R.id.tv_install, data.getORDER_TYPE());

        holder.setTextView(R.id.tv_install_date, data.getFINISH_DATE());
        holder.setTextView(R.id.tv_install_address, data.getADDR_AREA() + " " + data.getADDR_DETAIL());
    }
}
